home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Info 1994 March
/
Internet Info CD-ROM (Walnut Creek) (March 1994).iso
/
networking
/
ip
/
ka9q
/
net_des.arc
/
DESCRC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-05-05
|
782b
|
38 lines
/* Compute an "authentication code" or "cipher checksum" on a file by
* using DES as a one-way function. Useful for detecting file corruption
* by viruses, etc. 5 May 1988 Phil Karn
*/
#include <stdio.h>
main(argc,argv)
int argc;
char *argv[];
{
int mode = 0;
char tmp[8];
char buf[8];
int c;
while((c = getopt(argc,argv,"f")) != EOF){
switch(c){
case 'f':
mode = 1; /* DES without permutations */
break;
}
}
desinit(mode);
memset(tmp,'\0',8);
while(fread(buf,1,8,stdin) != 0){
setkey(buf);
endes(tmp);
}
printf("Cipher Checksum: %02x %02x %02x %02x %02x %02x %02x %02x\n",
tmp[0] & 0xff,
tmp[1] & 0xff,
tmp[2] & 0xff,
tmp[3] & 0xff,
tmp[4] & 0xff,
tmp[5] & 0xff,
tmp[6] & 0xff,
tmp[7] & 0xff);
}